function ngdomMap() {
	this.engine = ngdom.Engine;
	this.imagePath = '';
}
ngdomMap.prototype.loadImages = function(x, y) {
	if (typeof(x) == 'undefined') x = this.position.x;
	if (typeof(y) == 'undefined') y = this.position.y;
	
	this.loadImage(x, y);
	
	//precache
	this.loadImage(x - 1, y);
	this.loadImage(x + 1, y);
	this.loadImage(x, y - 1);
	this.loadImage(x, y + 1);
};
ngdomMap.prototype.loadImage = function(x, y) {
	if (x >= 0 && x < this.grid.length && y >= 0 && y < this.grid[this.position.x].length
	  && this.grid[x][y].img.src != this.engine.paths.scene+this.imagePath+x+'x'+y+'.jpg') 
	{
		this.grid[x][y].img.src = this.engine.paths.scene+this.imagePath+x+'x'+y+'.jpg';
		$.each(this.grid[x][y].objects, function (index, object) {
			if ($.isFunction(object.initSprites)) object.initSprites();
		});
	}
};
ngdomMap.prototype.addObject = function(object) {
	this.grid[this.position.x][this.position.y].objects[this.grid[this.position.x][this.position.y].objects.length] = object;
};
ngdomMap.prototype.initGrid = function() {
	this.grid = new Array();
	for (var x = 0; x < this.size.width; x++)
	{
		this.grid[x] = new Array();
		for (var y = 0; y < this.size.height; y++)
		{
			this.grid[x][y] = { img: new Image(), objects: [], walls: [], transitions: [] };
		}
	}
};